// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import router from './router';
import  axios  from '@/util/axios';
import auth from '@/util/auth';
import Code from '@/util/code';
import ElementUI from 'element-ui';
import FmGrid from '@/components/grid/FmGrid'
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false;

Vue.use(ElementUI,{size:'mini'});
Vue.component('fm-grid',FmGrid);
Vue.prototype.$auth = auth;
Vue.prototype.$code = new Code();
Vue.prototype.$session = {};

/* eslint-disable no-new */
const vue = new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
});

const dealError = (code,message) => {
  switch(code){
    case 203:
      vue.$router.push('/login')
      break;
    case 400:
      vue.$message.error(message||'参数错误');
      break;
    case 401:
      vue.$router.push('/noperm')
      break;
    case 500:
      vue.$message.error(message||'请求失败');
      break;
    default:
      break;
  }
}


export default dealError




